using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMRepairMaterialsController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;   
        #region[Get-Data]
        public DataTable BindGirdTMRepairMaterials_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMRepairMaterials_Detail_Edit", "@RepairMaterials_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMRepairMaterials(clsTMRepairMaterialsProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@RepairMaterials_Alias", data.RepairMaterials_Alias);
            cls.AddParameter("@RepairMaterials_Name", data.RepairMaterials_Name);
            cls.AddParameter("@RepairMaterials_Note", data.RepairMaterials_Note);
            cls.ExecuteNonQuery("sp_TMRepairMaterials_Insert");
            return true;
        }
        public bool UpdateTMRepairMaterials(clsTMRepairMaterialsProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@RepairMaterials_ID", data.RepairMaterials_ID);
            cls.AddParameter("@RepairMaterials_Alias", data.RepairMaterials_Alias);
            cls.AddParameter("@RepairMaterials_Name", data.RepairMaterials_Name);
            cls.AddParameter("@RepairMaterials_Note", data.RepairMaterials_Note);
            cls.ExecuteNonQuery("sp_TMRepairMaterials_Update");
            return true;
        }
        public bool DeleteTMRepairMaterials(int id)
        {
            cls.Delete("sp_TMRepairMaterials_Delete", "@RepairMaterials_ID", id);
            return true;
        }
        public bool TMRepairMaterials_Check_Delete_TMSymbolRepairMaterials(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMRepairMaterials_Check_Delete_TMSymbolRepairMaterials", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        public bool TMRepairMaterials_Check_Delete_TMCustomers(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMRepairMaterials_Check_Delete_TMCustomers", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMRepairMaterials_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}